package org.lisa.crm.controller.customer;

import org.lisa.crm.framework.context.BaseController;
import org.lisa.crm.model.CustomerLoss;
import org.lisa.crm.service.CustomerLossService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.servlet.ModelAndView;

import java.util.Map;

/**
 * Created by Administrator on 2018/2/3.
 */

@Controller
@RequestMapping("/customer_loss")
public class CustomerLossController  extends BaseController {

    @Autowired
    private CustomerLossService customerLossService;


    @GetMapping("index.shtml")
    public String index(){
        return "customer_loss";
    }

    //queryCustomerLossesByParams
    @RequestMapping("/queryCustomerLossesByParams")
    @ResponseBody
    public Map<String,Object> queryCustomerLossesByParams(CustomerLoss customerLoss){

        return customerLossService.queryCustomerLossesByParams(customerLoss);

    }

    //"/customer_loss/"+lossId+"/customerRepriPage.html
    @RequestMapping("{lossId}/customerRepriPage")
    public ModelAndView customerRepriPage(@PathVariable("lossId") int  lossId ){

        CustomerLoss customerLoss=customerLossService.queryCustomerLossById(lossId);
        ModelAndView mv=new ModelAndView();
        //要和视图的文件名称保持一致
        mv.setViewName("customer_repri");
        mv.addObject("customerLoss",customerLoss);
        return mv;

    }
}
